package com.duotai.duotai4;

import java.util.ArrayList;

public class Dao {
    static ArrayList<People> p = new ArrayList<People>();

    //将对象存入到集合中
    static{
        p.add(new Student(1,"张三丰","太极拳"));//0
        p.add(new Student(2,"叶问","咏春"));//1
        p.add(new Student(3,"张无忌","九阳神功"));//2
        p.add(new Teacher(4,"张雪峰","考研"));//3
        p.add(new Teacher(5,"刘晓燕","英语"));//4
    }

    public static void main(String[] args) {
        System.out.println(Dao.p);
        System.out.println("--------------------------");
        System.out.println(Dao.p.get(0));
        System.out.println(Dao.p.get(3));
        System.out.println("--------------------------");
        System.out.println(Dao.p.get(1).getName());
        //Student s = (Student)Dao.p.get(1);
        //Teacher teacher = (Teacher)Dao.p.get(1);
        if(Dao.p.get(3) instanceof Student){
            Student s = (Student)Dao.p.get(3);
            System.out.println(s.getMajor());
        }




    }
}
